function Ocean(cxt,sx,ex,sy,ey,spd,freq) {
	
	var islandPool = new Array();
	var island = new Array();
	var context = cxt;
	var MAX_island_POOL = 100;
	var starty = sy;
	var endy = ey;
	var startx = sx;
	var endx = ex;
	var speed = spd;
	var frequency = freq;
	var islandImages = new Array();
	var tempImage1 = new Image();
	var tempImage2 = new Image();
	var tempImage3 = new Image();
	tempImage1.onload = this.imageLoaded;
	tempImage1.src = "island1.gif";
	islandImages.push(tempImage1);
	tempImage2.onload = this.imageLoaded;
	tempImage2.src = "island2.gif";
	islandImages.push(tempImage2);
	tempImage3.onload = this.imageLoaded;
	tempImage3.src = "island3.gif";
	islandImages.push(tempImage3);
	var createWait = 20;
	var createWaitCount = 10;
	
	this.draw = function() {
	
		var rnd =Math.floor(Math.random() * 100);
		//Debugger.log("draw island:" +	 rnd);
		var rndx =Math.floor(Math.random() * (endx-startx)) + startx;
		//var rndx =Math.floor(Math.random() * endx);
		var rndIsland = Math.floor(Math.random() * islandImages.length);
		createWaitCount++;
		if (rnd < frequency  && createWaitCount >= createWait) {
			createWaitCount = 0;
			Debugger.log("CREATE island");
			if (islandPool.length > 0) {
				var tempisland = islandPool.pop();
				tempisland.x = rndx;
				tempisland.y = starty;
				tempisland.image = islandImages[rndIsland];
				island.push(tempisland);
			} else {
				island.push({x:rndx,y:starty,image:islandImages[rndIsland]});
			}	
		}
		
		for (var i=island.length-1; i>= 0;i--) {;
			island[i].y += speed;
			//Debugger.log(island.y)
			
			if (island[i].y >= endy ) {
				if (islandPool.length < MAX_island_POOL) {
					islandPool.push(island.splice(i,1));
				} else {
					island.splice(i,1);
				}
			} else {
				context.drawImage(island[i].image,island[i].x,island[i].y);
			}
			
		}
	}

}
